
use "$LocalData\CountyIndustryEmp_2digit_RFS.dta", clear

sort geoind year

gen LgSmallFirmnoti3 = L3.gSmallFirmnoti3
gen LgLargeFirmnoti3 = L3.gLargeFirmnoti3
gen LgSmallFirmnoti1 = L.gSmallFirmnoti1
gen LgLargeFirmnoti1 = L.gLargeFirmnoti1
gen L3small_dep_share = L3.small_dep_share

gen LgSmallFirmnoti5 = L5.gSmallFirmnoti5
gen LgLargeFirmnoti5 = L5.gLargeFirmnoti5
gen L5small_dep_share = L5.small_dep_share


gen LgSmallFirmCounty3 = L3.gSmallFirmCounty3

egen industry_year = group(industry year)

preserve
	local controls 	dlngdp unem_change pop_growth annualchange
	replace unem_change = unem_change/100
	replace annualchange = annualchange/100

	keep if !missing(gSmallFirm3) & !missing(LgSmallFirmnoti3) & !missing(LgLargeFirmnoti3) & !missing(gLargeFirm3) & L3.county_emp0>10000 & L3.emp_size1>200 & (year==2002 | year==2005  | year==2008 | year==2011  | year==2014  | year==2017) & c_i_share_2000<0.5
	su gSmallFirm3 LgSmallFirmnoti3 LgLargeFirmnoti3 gLargeFirm3 

	eststo: reghdfe gSmallFirm3 c.LgSmallFirmnoti3##c.small_dep_share2000 , absorb(geography industry_year) cluster(geography)
	outreg2 using "$LocalData\Tables\RFS_Spillover",  tex replace ///
	ctitle("\Delta ln(SmEmp)") addtext(REG, OLS, COUNTY FE, YES, IND-YR FE, YES)
	
	eststo: reghdfe gSmallFirm3 c.LgSmallFirmnoti3##c.small_dep_share2000 `controls', absorb(geography industry_year) cluster(geography)
	outreg2 using "$LocalData\Tables\RFS_Spillover",  tex append ///
	ctitle("\Delta ln(SmEmp)") addtext(REG, OLS, COUNTY FE, YES, IND-YR FE, YES)

	eststo: reghdfe gSmallFirm3 c.LgLargeFirmnoti3##c.small_dep_share2000 , absorb(geography industry_year) cluster(geography)
	outreg2 using "$LocalData\Tables\RFS_Spillover",  tex append ///
	ctitle("\Delta ln(SmEmp)") addtext(REG, OLS, COUNTY FE, YES, IND-YR FE, YES)

	eststo: reghdfe gSmallFirm3 c.LgLargeFirmnoti3##c.small_dep_share2000 `controls', absorb(geography industry_year) cluster(geography)
	outreg2 using "$LocalData\Tables\RFS_Spillover",  tex append ///
	ctitle("\Delta ln(SmEmp)") addtext(REG, OLS, COUNTY FE, YES, IND-YR FE, YES)

	eststo: reghdfe gLargeFirm3 c.LgSmallFirmnoti3##c.small_dep_share2000 , absorb(geography industry_year) cluster(geography)
	outreg2 using "$LocalData\Tables\RFS_Spillover",  tex append ///
	ctitle("\Delta ln(LgEmp)")addtext(REG, OLS, COUNTY FE, YES, IND-YR FE, YES)

	eststo: reghdfe gLargeFirm3 c.LgSmallFirmnoti3##c.small_dep_share2000 `controls' , absorb(geography industry_year) cluster(geography)
	outreg2 using "$LocalData\Tables\RFS_Spillover",  tex append ///
	ctitle("\Delta ln(LgEmp)")addtext(REG, OLS, COUNTY FE, YES, IND-YR FE, YES)

	eststo: reghdfe gLargeFirm3 c.LgLargeFirmnoti3##c.small_dep_share2000 , absorb(geography industry_year) cluster(geography)
	outreg2 using "$LocalData\Tables\RFS_Spillover",  tex append ///
	ctitle(" \Delta ln(LgEmp)") addtext(REG, OLS, COUNTY FE, YES, IND-YR FE, YES)

	eststo: reghdfe gLargeFirm3 c.LgLargeFirmnoti3##c.small_dep_share2000 `controls', absorb(geography industry_year) cluster(geography)
	outreg2 using "$LocalData\Tables\RFS_Spillover",  tex append ///
	ctitle(" \Delta ln(LgEmp)") addtext(REG, OLS, COUNTY FE, YES, IND-YR FE, YES)

restore
